package com.shareach.domain;

import java.util.Arrays;
import java.util.Date;

import org.apache.commons.lang.StringUtils;
import org.springframework.data.mongodb.core.mapping.Document;

import com.shareach.domain.common.Entity;
import com.shareach.util.Globals;

/**
 * create time：2013-1-31 下午2:37:34
 * 
 * @author retryu
 * @since JDK 1.6
 * @version 1.0 description：
 */

@Document(collection = "bizActivity")
public class BizActivityDomain extends Entity {

	// 标题
	private String title;
	// 活动商家数
	private Long shopCount;
	// 描述
	private String descr;
	// 图片
	private String img;
	// 城市 参见 城市BaseCity
	private Long city;

	private String cityName;
	// 城市Id
	private Long bankId;
	// 银行卡总ID
	private Integer bankCardId;
	// 活动规则
	private String discountRule;
	// 状态
	private Integer status;
	// 一周打折日
	private Integer[] discountWeek;
	// 起始
	private Date start;
	// 截至日期
	private Date end;
	// 关键词
	private String keyword;
	// 消费领域
	private String campCat;
	// 活动给力程度评分
	private String campRat;
	// 活动图片ID
	private String picId;
	// 更新时间或者创建时间
	private Date updateTime = new Date();
	// 上架时间
	private Date deployTime;
	// 创建时间
	private Date creatTime;
	// sid
	private String sid;

	public String getCampRat() {
		return campRat;
	}

	public void setCampRat(String campRat) {
		this.campRat = campRat;
	}

	public String getPicId() {
		return picId;
	}

	public void setPicId(String picId) {
		this.picId = picId;
	}

	public Date getCreatTime() {
		return creatTime;
	}

	public void setCreatTime(Date creatTime) {
		this.creatTime = creatTime;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public Date getDeployTime() {
		return deployTime;
	}

	public void setDeployTime(Date deployTime) {
		this.deployTime = deployTime;
	}

	public String getTitle() {
		return title;
	}

	public String getKeyword() {
		return keyword;
	}

	public void setKeyword(String keyword) {
		this.keyword = keyword;
	}

	public String getCampCat() {
		return campCat;
	}

	public void setCampCat(String campCat) {
		this.campCat = campCat;
	}

	public Integer[] getDiscountWeek() {
		return discountWeek;
	}

	public void setDiscountWeek(Integer[] discountWeek) {
		this.discountWeek = discountWeek;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public Long getShopCount() {
		return shopCount;
	}

	public void setShopCount(Long shopCount) {
		this.shopCount = shopCount;
	}

	public String getDescr() {
		return descr;
	}

	public void setDescr(String descr) {
		this.descr = descr;
	}

	public String getImg() {
		return img;
	}

	public void setImg(String img) {
		this.img = img;
	}

	public Long getCity() {
		return city;
	}

	public void setCity(Long city) {
		this.city = city;
	}

	public Long getBankId() {
		return bankId;
	}

	public void setBankId(Long bankId) {
		this.bankId = bankId;
	}

	public Integer getBankCardId() {
		return bankCardId;
	}

	public void setBankCardId(Integer bankCardId) {
		this.bankCardId = bankCardId;
	}

	public String getDiscountRule() {
		return discountRule;
	}

	public void setDiscountRule(String discountRule) {
		this.discountRule = discountRule;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public Date getStart() {
		return start;
	}

	public void setStart(Date start) {
		this.start = start;
	}

	public Date getEnd() {
		return end;
	}

	public void setEnd(Date end) {
		this.end = end;
	}

	public String getCityName() {
		return cityName;
	}

	public void setCityName(String cityName) {
		this.cityName = cityName;
	}

	public String getSid() {
		return sid;
	}

	public void setSid(String sid) {
		this.sid = sid;
	}

	public BizActivityDomain compareTo(BizActivityDomain domain) {
		BizActivityDomain change = new BizActivityDomain();

		if (domain == null) {
			return change;
		}

		if (StringUtils.isNotEmpty(domain.getTitle())) {
			if (this.title == null || !this.title.trim().equals(domain.getTitle().trim())) {
				change.setTitle(domain.getTitle().trim());
			}
		}

		if (domain.getShopCount() != null) {
			if (this.shopCount == null || !this.shopCount.equals(domain.getShopCount())) {
				change.setShopCount(domain.getShopCount());
			}
		}

		if (StringUtils.isNotEmpty(domain.getDescr())) {
			if (this.descr == null || !this.descr.trim().equals(domain.getDescr().trim())) {
				change.setDescr(domain.getDescr().trim());
			}
		}

		if (StringUtils.isNotEmpty(domain.getImg())) {
			if (this.img == null || !this.img.trim().equals(domain.getImg().trim())) {
				change.setImg(domain.getImg().trim());
			}
		}

		if (domain.getCity() != null) {
			if (this.city == null || !(this.city.equals(domain.getCity()))) {
				change.setCity(domain.getCity());
			}
		}

		if (StringUtils.isNotEmpty(domain.getCityName())) {
			if (this.cityName == null || !this.cityName.trim().equals(domain.getCityName().trim())) {
				change.setCityName(domain.getCityName().trim());
			}
		}

		if (domain.getBankId() != null) {
			if (this.bankId == null || !this.bankId.equals(domain.getBankId())) {
				change.setBankId(domain.getBankId());
			}
		}

		if (StringUtils.isNotEmpty(domain.getDiscountRule())) {
			if (this.discountRule == null || !this.discountRule.trim().equals(domain.getDiscountRule().trim())) {
				change.setDiscountRule(domain.getDiscountRule().trim());
			}
		}

		if (domain.getStatus() != null) {
			if (this.status == null || !this.status.equals(domain.getStatus())) {
				change.setStatus(domain.getStatus());
			}
		}

		if (domain.getDiscountWeek() != null && domain.getDiscountWeek().length > 0) {
			if (this.discountWeek == null || !Arrays.equals(this.discountWeek, domain.getDiscountWeek())) {
				change.setDiscountWeek(domain.getDiscountWeek());
			}
		}

		if (domain.getStart() != null) {
			if (!Globals.FORMAT_TYPE_A.format(this.start).equals(Globals.FORMAT_TYPE_A.format(domain.getStart()))) {
				change.setStart(domain.getStart());
			}
		}

		if (domain.getEnd() != null) {
			if (this.end == null
					|| !Globals.FORMAT_TYPE_A.format(this.end).equals(Globals.FORMAT_TYPE_A.format(domain.getEnd()))) {
				change.setEnd(domain.getEnd());
			}
		}

		if (StringUtils.isNotEmpty(domain.getKeyword())) {
			if (this.keyword == null || !this.keyword.trim().equals(domain.getKeyword().trim())) {
				change.setKeyword(domain.getKeyword().trim());
			}
		}

		if (StringUtils.isNotEmpty(domain.getCampCat())) {
			if (this.campCat == null || !this.campCat.trim().equals(domain.getCampCat().trim())) {
				change.setCampCat(domain.getCampCat().trim());
			}
		}

		if (StringUtils.isNotEmpty(domain.getCampRat())) {
			if (this.campRat == null || !this.campRat.trim().equals(domain.getCampRat().trim())) {
				change.setCampRat(domain.getCampRat().trim());
			}
		}

		if (StringUtils.isNotEmpty(domain.getPicId())) {
			if (this.picId == null || !this.picId.trim().equals(domain.getPicId().trim())) {
				change.setPicId(domain.getPicId().trim());
			}
		}

		if (StringUtils.isNotEmpty(domain.getSid())) {
			if (this.sid == null || !this.sid.trim().equals(domain.getSid().trim())) {
				change.setSid(domain.getSid().trim());
			}
		}
		return change;
	}

}
